package fun.coding.search;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class BinarySearchMain {
    public static void main(String[] args) {
        
        BinarySearch bs = new BinarySearchImpl();
        /*
        List<int[]> testList = new LinkedList<int[]>();
        
        testList.add(new int[] {1, 2, 3, 4, 5}); 
        testList.add(new int[] {4, 5, 1, 2, 3});
        testList.add(new int[] {4, 5, 6, 1, 2, 3});
        testList.add(new int[] {5, 1, 2, 3, 4});
        testList.add(new int[] {5, 6, 1, 2, 3, 4});
        testList.add(new int[] {2, 1});
        testList.add(new int[] {1, 2});
        testList.add(new int[] {2, 3, 1});
        testList.add(new int[] {1});
        
        for(int[] a : testList) {
            System.out.println(bs.findMinimumShiftedArray(a, 0, (a.length - 1)));
        }
        */
        
      //  int[] a = {3, 7, 6, 5, 2, 5, 5, 5, 5};
        /*
        int[] a = {3, 7, 6, 5, 2, 1};
        
        Arrays.sort(a);
        
        for(int i = 0;i < a.length; ++i) {
            System.out.println(a[i]);
        }
        
       // System.out.println("index is " + bs.binarySearch(a, 5, 0, a.length - 1));
        System.out.println("index is " + bs.binarySearchFirstAppearance(a, 5, 0, a.length - 1));
        */
        
        //int[] a = {6, 7, 2, 3, 4, 5};
        int[] a = {2, 3, 4, 5, 1};
        System.out.println("index is " + bs.binarySearchShifted(a, 5, 0, a.length - 1));
        System.out.println("minimum is " + bs.binarySearchShiftedMin(a, 0, a.length - 1));
        
        int[] array = {2, 5, 5, 5, 7, 9};
        System.out.println(bs.countOccurance(array, 5));
    }
}
